package com.situ.javase.day10;

public class ThreadDemo {

	// 进程里面至少要有一个线程，
	// 运行main方法默认执行的就是主线程
	public static void main(String[] args) {
		// System.out.println(Thread.currentThread().getName());;
		
		MyThread myThread = new MyThread("MyThread");
		// 这不是启动一个线程，这是调用对象里面一个普通方法run方法
		// myThread.run();
		// 真正启动一个线程调用start()方法，执行的代码就是run方法里面的代码
		myThread.start();
	}
	
	
	public static void main2(String[] args) {
		MyRunnable myRunnable = new MyRunnable();
		Thread thread = new Thread(myRunnable);
		thread.start();
	}
	
	public static void main44(String[] args) {
		MyRunnable myRunnable = new MyRunnable();
		Thread thread = new Thread(myRunnable);
		thread.start();
		
		String name = Thread.currentThread().getName();
		for (int i = 0; i < 100; i++) {
			System.out.println(name + " ：" + i);
			try {
				// 让当前线程停止50毫秒
				Thread.sleep(50);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}
	
	public static void main11(String[] args) {
		JiShuRunnable jiShuRunnable = new JiShuRunnable();
		Thread jiShuThread = new Thread(jiShuRunnable, "奇数线程");
		jiShuThread.start();
		OuShuRunnable ouShuRunnable = new OuShuRunnable();
		Thread ouShuThread = new Thread(ouShuRunnable, "偶数线程");
		ouShuThread.start();
	}
}
